<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : Multiplier : : setValue</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">

  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName"><A href="multiplier_class_multiplier.html">Multiplier</A></p>
    	<p class="methodName">setValue</p>
    </td>
    <td class="mainText border-left">
    	<p class="memberSectionHeader">Description</p>
    	Set the amplitude of this Multiplier.
    	
    	<p class="memberSectionHeader">Signature</p>
    	<pre>void setValue(float value)
</pre>
    	
    	
   <p class="memberSectionHeader">Parameters</p>
   
        <span class="parameterName">value</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: the new amplitude for the Multiplier</span><br/>
    
   
    	
   <p class="memberSectionHeader">Returns</p> 
   <p>None</p>
   
    	
    	<p class="memberSectionHeader">Related</p>
    	<A href="multiplier_field_amplitude.html">amplitude</A><BR>
<A href="multiplier_class_multiplier.html">Multiplier</A><BR>
<A href="ugen_class_ugen.html">UGen</A><BR>

    	
    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  This is an example of using a Multiplier UGen, which performs the very simple operation of 
  multiplying the incoming signal by the current value of its amplitude input.
  &lt;p>
  Move the mouse left and right to change the value of the Multiplier. 
  All the way left is 0.1 and all the way right is 1.
  &lt;p>
  For more information about Minim and additional features,&lt;br/>
  visit http://code.compartmental.net/minim/
  &lt;p>
  author: Damien Di Fede
*/

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim         minim;
AudioOutput   out;
Oscil         osc;
Multiplier    multiplier;

void setup()
{
  // setup the size of the app
  size(640, 200);
  
  // create our Minim object for loading audio
  minim = new Minim(this);
  
  // get a line out from Minim. It's important that the file is the same audio format 
  // as our output (i.e. same sample rate, number of channels, etc).
  out = minim.getLineOut();
  
  osc = new Oscil( 440, 1 );
  multiplier = new Multiplier( 0.5f );
  
  // normally we wouldn't use a multiplier with an Oscil like this
  // because we could simply set the amplitude of the Oscil itself.
  osc.patch( multiplier ).patch( out );
                        
}

// draw is run many times
void draw()
{
  // map the mouse position to a new value for the multiplier
  float value = map(mouseX, 0, width, 0.1, 1);
  
  // set the new value.
  // this is equivalent to multiplier.amplitude.setLastValue( value )
  // you'll also notice this causes audible clicks if you move the mouse quickly
  // to keep that from happening, you will usually want to use a Line patched 
  // to the Multiplier's amplitude input.
  multiplier.setValue( value );
  
  // erase the window to black
  background( 0 );
  // draw using a white stroke
  stroke( 255 );
  // draw the waveforms
  for( int i = 0; i &lt; out.bufferSize() - 1; i++ )
  {
    // find the x position of each buffer value
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    float x2  =  map( i+1, 0, out.bufferSize(), 0, width );
    // draw a line from one buffer position to the next for both channels
    line( x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
    line( x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
  }  
}

</pre>
    	
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>
